package com.mashibing.strategy;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * writing tests first!
 * extreme programming
 */
public class Main {
    public static void main(String[] args) {
        //int[] a = {9, 2, 3, 5, 7, 1, 4};
        Cat[] a = {new Cat(3, 3), new Cat(5, 5), new Cat(1, 1)};
        //Dog[] a = {new Dog(3), new Dog(5), new Dog(1)};
        Sorter<Cat> sorter = new Sorter<>();
        sorter.sort(a, (o1, o2) -> {
            if (o1.weight < o2.weight) {
                return -1;
            } else if (o1.weight > o2.weight) {
                return 1;
            } else {
                return 0;
            }
        });
        System.out.println(Arrays.toString(a));
        System.out.println("======================================================================");
        List<Cat> cats = new ArrayList<Cat>() {{
            add(new Cat(3, 1));
            add(new Cat(45, 90));
            add(new Cat(12, 32));
            add(new Cat(22, 12));

        }};
        cats.sort(new Comparator<Cat>() {
            @Override
            public int compare(Cat o1, Cat o2) {
                return o1.height - o2.height;
            }
        });
        System.out.println(cats);
    }
}
